var api = require('../../utils/api.js')

Page({
    data: { 
        result:[] 
    },
    onLoad (params) {
        this.params = params;
        this.setEdit();
    },
    setEdit: function(e) {
        api.get({
            url: 'user/profile/userinfo',
            data: {},
            success: res => {
                if (res.code == 1) {
                    var detail = res.data;
                    this.setData({ 
                        result: detail,
                    });
                }
            }
        });
    },
    bindPickerChange: function(e) {
        this.setData({
            zone_id: e.detail.value
        })
    },

    formSubmit(e){
        api.post({
            url: 'user/profile/userinfo',
            data: e.detail.value,
            success: data => {
                if (data.code == 1) {
                    wx.showToast({
                        title: data.msg,
                        icon: 'success',
                        duration: 800
                    })
                    setTimeout(function(){ wx.switchTab({ url: '/pages/my/my'}); }, 800);
                }
                if (data.code == 0) {
                    wx.showModal({
                        content: data.msg,
                        showCancel: false,
                        success: function (res) {
                            if (res.confirm) {
                                console.log('用户点击确定')
                            }
                        }
                    })
                }
            }
        });
        //console.log(e);
    }


});